package com.hmsm.server.quartz;

import java.util.Calendar;
import java.util.Map.Entry;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hmsm.server.common.AllContext;
import com.hmsm.sys.service.IHourTask;
import com.hmsm.sys.service.IScheduledTask;

/**
 * 系统定时任务
 * @author admin
 *
 */
public class BusinessObject {
	
	private static final Log log = LogFactory.getLog(BusinessObject.class);
	
	public void initexc() {
		
		Calendar calendar = Calendar.getInstance();
		int hour = calendar.get(Calendar.HOUR_OF_DAY);
		int minute = calendar.get(Calendar.MINUTE);
		
		log.info("定时任务开始运行，当前时间："+hour+":"+minute+"");
		for(Entry<String, IScheduledTask> entry:AllContext.getAppContext().getBeansOfType(IScheduledTask.class).entrySet()){
			IScheduledTask service = entry.getValue();
			service.execTask();
		}
		for(Entry<String, IHourTask> entry:AllContext.getAppContext().getBeansOfType(IHourTask.class).entrySet()){
			IHourTask service = entry.getValue();
			service.execTask();
		}
		log.info("定时任务运行结束，当前时间："+hour+":"+minute+"");
	}

	
}
